package com.kuang.lesson02;

import utils.JdbcUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TextSelect {
    public static void main(String[] args) {
        Connection conn =null;
        Statement st = null;
        ResultSet rs = null;
        try {
             conn = JdbcUtils.getConnection();
             st=conn.createStatement();
             String sql ="select * from users where id =1";
             rs = st.executeQuery(sql);
             if (rs.next()){
//                 getString中要带双引号
                 System.out.println("id:"+rs.getInt("id"));
                 System.out.println("name:"+rs.getString("name"));
                 System.out.println("email:"+rs.getString("email"));
                 System.out.println("birth:"+rs.getString("birthday"));
             }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.release(conn,st,rs);
        }
    }
}
